from enum import Enum


class InstructionType(Enum):
    HELP = 1   # 帮助 关键字: <帮助>
    KUMQUAT_INFO = 2  # 获取金桔介绍信息 关键字: <介绍金桔> <介绍滑皮> <介绍脆蜜>
    BAVARDER = 3  # 闲聊

    REGISTRY_USER = 10   # 把我注册为用户 关键字: <注册>
    DELETE_USER = 19  # # 如果信息不对，删除用户，重新注册，也不需要大模型 关键字: <删除/删掉>
    IMPORT_EXCEL_ORDER = 11  # 导入订单 关键字: 引用 or <导入>
    IMPORT_BY_WORDS = 12  # 语言导入单个订单 关键字: <加一单>, <加单>
    CHANGE_ORDER = 13  # 语言修改订单 关键字: <改一单>
    DEL_ORDER = 14  # 删除订单 关键字: <删一单>
    REPORT_ORDERS = 15  # 汇总订单 关键字: <报告>, <从[开始日期]到[结束日期]>, <汇总所有>, <汇总我>
    REPORT_TODAY = 16  # 今日汇总 关键字: <今日统计>, <汇总今天>, <装果>
    CHECK_MYTODAY = 17  # 查看今日订单 关键字: <查今日>, <查我今日>, <查我今天订单>, <查今天订单>
    GET_TEMPLATE_KEYS = 18  # 下载模板文件 关键字: <订单模板>,<金桔模板>,<模板>
    # GET_KUMQUAT_TEMPLATE_FILE = 19  # 下载模板文件 关键字: <金桔模板>


    CHECK_USER_ALREADY_EXISTS = 40  # 用户已经存在，只需要返回不敏感信息
    CHECKSUM_FILE = 41

    def __str__(self):
        return self.name

    def compare(self, other):
        return self.value is other.value and self.name is other.name


class ActionType(Enum):
    CHECK_USER_EXISTS = 1
    ASK_OLLAMA = 2
    ASK_OTHER_AI = 3
    HANDLER_QUERY = 4
    PREPARE_RESPONSE = 5
    CHECK_PERMISSION = 6
    CHECK_HAS_KUMQUAT_DATA = 7
    GET_USER_KUMQUATS = 8

    CHECKSUM_ORDER_PASS = 10
    CHECKSUM_KUMQUAT_PASS = 11
    CHECKSUM_FAILED = 12
    CLEAN_EXCEL_DATA = 13
    ORDER_FIEDLS_EMPTY = 14
    ORDER_KUMQUAT_FIELDS_ERROR = 15
    KUMQUAT_FIEDLS_EMPTY = 16
    KUMQUAT_VALUE_ERROR = 17
    INSERT_EXCEL = 18
    ORDER_VALUE_ERROR = 19
    INSERT_EXCEL_FAILED = 20
    UPDATE_TO_OLD_KUMQUAT = 21
    DELETE_BAD_FILE = 22
    REPORT_LOADED_FILE = 23
    RENAME_TO_DONE = 24
    IMPORT_FAILED = 25

    FILTER_ORDER_DATE = 30
    BUILD_ORDER_REPORT_DF = 31
    SAVE_SHUNFENG_EXCEL = 32
    INSER_WORD_QUERY = 33

    OLLAMA_NOT_RUNNING = 50
    OLLAMA_UNFOUND_MODEL = 51
    ONLINE_AI_UNREACHABLE = 52

    REGISTRY_FAILED = 60
    REGISTRY_SUCCESS = 61
    DELETE_SUCCESS = 62
    DELETE_FAILED = 63

    CHECK_DEADLINE = 64
    CHECK_MSG_TYPE = 65

    QUERY_COMPLETED = 100

    JSON_ERROR = 150
    HANDLER_QUERY_FAILED = 151
    OVER_DEADLINE = 152
    UNKNOWN_ERROR = 153

    #  Complain..
    AI_IS_STUPID = 666

    def __str__(self):
        return self.name

    def compare(self, other):
        return self.value is other.value and self.name is other.name


class ExcelType(Enum):
    ORDER = 1
    KUMQUAT = 2

    def __str__(self):
        return self.name

    def compare(self, other):
        return self.value is other.value and self.name is other.name
